package org.shareworth.online_life.client.mvc;

import org.shareworth.online_life.client.module.login.LoginDialog;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.state.StateManager;
import com.extjs.gxt.ui.client.widget.MessageBox;

public class AppView extends View {

	public AppView(Controller controller) {
		super(controller);
	}

	@Override
	protected void handleEvent(AppEvent event) {
		if (AppEvents.Init == event.getType())

			initUI();
		else if (AppEvents.Login == event.getType())

			new LoginDialog().show();

	}

	private void initUI() {
		MessageBox wait = MessageBox.wait("", "", "程序启动中");
		StateManager.get().set("login", true);
	}

	@Override
	protected void initialize() {
		// LoginDialog dialog = new LoginDialog();
		// dialog.setClosable(false);
		// dialog.addListener(Events.Hide, new Listener<WINDOWEVENT>() {
		// public void handleEvent(WindowEvent be) {
		// Dispatcher.forwardEvent(AppEvents.Init);
		// }
		// });
		// dialog.show();
		// }
		// Window window = new Window();
		// Button button = new Button("点击初始化");
		// window.add(button);
		// button.addSelectionListener(new SelectionListener<ButtonEvent>() {
		//
		// @Override
		// public void componentSelected(ButtonEvent ce) {
		// Dispatcher.forwardEvent(AppEvents.Init);
		//
		// }
		//
		// });
		// window.show();

	}

}
